﻿using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;

using System;
using System.Collections.Generic;
using System.Linq;

namespace Nemerle2.Compiler
{
  /// <summary>
  /// Переменная типа. Используется в процессе вывода типов.
  /// </summary>
  public sealed class TypeVar : NType
  {    
    public this(solver : Solver)
    {
      Solver = solver;
    }   
    
    public Solver : Solver { get; }
    
    /// <summary> Нижняя граница типа.</summary>  
    public LowerBound : ValueOption [FixedType]
    {
      get
      { 
        def b = Self._lowerBound;
        if (b == null) ValueOption.None ()
        else ValueOption.Some (b)
      }
    }
    
    /// <summary> Верхняя граница типа.</summary>
    public UpperBound : ValueOption [FixedType]
    {
      get
      {
        def b = Self._upperBound;
        if (b == null) ValueOption.None ()
        else ValueOption.Some (b)
      }
    }
    
    public Hint : option [FixedType]
    {
      get 
      {
        throw NotImplementedException()
        //def s = Self;
        //def ub = s._upperBound;
        //def lb = s._lowerBound;

        //if (ub == null)
        //  if (lb == null || lb.Equals(InternalTypes.Object))
        //    None ()
        //  else
        //    Some (lb)
        //else Some (ub)
      }
    }

    
    private _lowerBound : FixedType = null;
    private _upperBound : FixedType = null;
    
    protected Self : TypeVar
    {
      get 
      {
        //WillRead ();
        //if (flags %&& Flags.IsAliased)
        //  alias_to.Self
        //else
          this
      }
    }


  }
}
